<template>
	<view class="">
		<u-navbar :border-bottom="false" title-color="#333" title-bold title="我的案例" title-size="36"></u-navbar>
		<view class="tab-div">
			<view class="anli">
				<view class="flex flex_end ">
					<view class="gl-btn"  @click="delshow=!delshow">
						<u-icon name="list-dot" color="#666" size="28"></u-icon>
						管理
					</view>
				</view>
				
				<u-time-line>
					<u-time-line-item nodeTop="12" v-for="(item2,index2) in anliList" :key="index2">
						<template v-slot:node>
							<view class="u-node"></view>
						</template>
						<template v-slot:content>
							<view @click="todetail(1,item2)">
								<view class="">
									<span class="u-order-title">{{item2.created_at}}</span>
								</view>
								<view class="flex flex_sb">
									<view class="u-order-desc">
										{{item2.title}}
									</view>
									<view class="del-icon u-m-l-10" v-if="delshow">
										<image @click.stop="del(item2)" class="del-icon" src="../../../../static/img/home/del-icon.png" mode=""></image>
									</view>
								</view>
								
							</view>
						</template>
					</u-time-line-item>
				</u-time-line>
				
			</view>
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="add">
				添加
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				delshow:false,
				anliList:[],
				
				total:0,
				pageNum:1,
				pageSize:20,
			}
		},
		onReachBottom() {
			if (this.pageNum * this.pageSize > this.total) {
				// uni.hideNavigationBarLoading();
			} else {
				this.pageNum++;
				this.getanli()
			}
		},
		onShow() {
			this.pageNum = 1
			this.getanli()
		},
		methods: {
			getanli(){
				this.$api({
					url: '/lawyer/my_getCaseList',
					method: 'get',
					data: {
						page:this.pageNum,
						limit:this.pageSize,
						token:uni.getStorageSync("token"),
						lawyer_id:0 //律师ID，所有数据传-1，自己数据传0，其它律师数据传具体ID
					},
				}).then(res => {
					if (res.code == 1) {
						// this.anliList = res.data.list
						this.total=res.data.count
						let data = res.data.list
						if (this.pageNum == 1) {
							this.anliList = data
						} else {
							this.anliList = [...this.anliList, ...data]
						}
					} 
				})
			},
			del(e){
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认删除吗',
					success: function(res) {
						if (res.confirm) {
							that.$api({
								url: '/lawyer/delCaseInfo',
								method: 'post',
								data: {
									token:uni.getStorageSync("token"),
									ids:e.id
								},
							}).then(res => {
								if (res.code == 1) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									that.getanli()
								} 
							})
						}
					}
				});
			},
			todetail(e,item) {
				uni.navigateTo({
					url: "/pages/lawyer/anliDetail?type=" + e+"&id="+item.id
				})
			},
			add(){
				uni.navigateTo({
					url: "/subPackageA/pages/lawyerVersion/mine/addanli"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.del-icon{
		width: 40rpx;
		height: 40rpx;
	}
	.btn-bo{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0,0,0,0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;
		
		.btn_login_btn{
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}
	.gl-btn{
		width: 130rpx;
		height: 48rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		border: 2rpx solid #605F6A;
		text-align: center;
		line-height: 48rpx;
	}
	.tab-div {
		width: 686rpx;
		// height: 672rpx;
		padding: 32rpx;
		// background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
	}

	.anli {
		.u-node {
			width: 12rpx;
			height: 12rpx;
			background: #FC3A30;
			border-radius: 50%;
		}

		.u-order-title {
			font-size: 20rpx;
			color: #666666;
			padding: 6rpx 12rpx;
			background: #F4F4F4;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
		}

		.u-order-desc {
			font-size: 28rpx;
			color: #000000;
			line-height: 48rpx;
			margin-top: 26rpx;
		}
	}
</style>